package com.pengtu.gsj.service.impl.lzgl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.pengtu.gsj.dao.base.Page;
import com.pengtu.gsj.dao.base.QueryFilter;
import com.pengtu.gsj.dao.lzgl.InPorMatDao;
import com.pengtu.gsj.entity.app.Attachment;
import com.pengtu.gsj.entity.lzgl.InPorMat;
import com.pengtu.gsj.service.lzgl.InPorMatService;
import com.pengtu.gsj.service.system.SystemManageService;

/**
 * 
 * InPorMatServiceImpl
 * 
 * 2017年9月12日 下午6:21:16
 * 
 * @version 1.0.0
 * 
 */
@Service
@Transactional
public class InPorMatServiceImpl implements InPorMatService {

	@Autowired
	private InPorMatDao inPorMatDao;
	@Autowired
	private SystemManageService systemManageService;
	
	@Override
	public void saveInPorMat(InPorMat inPorMat){
		inPorMatDao.save(inPorMat);
	}
	
	@Override
	public Page<InPorMat> findInPorMat(Page<InPorMat> page, final QueryFilter queryFilter){
		return inPorMatDao.findPage(page, queryFilter);
	}
	
	@Override
	public InPorMat getInPorMatById(String id){
		return inPorMatDao.get(id);
	}
	
	@Override
	public void  delateInPorMat(InPorMat inPorMat){
		if(inPorMat.getAttachments() != null){
			for(Attachment attachment : inPorMat.getAttachments()){
				systemManageService.deleteAttachment(attachment);
			}
		}
		inPorMatDao.delete(inPorMat);
	}

	/**
	 * 适用：获得涉路工程监管页面下拉框数据
	 */
	@Override
	public List<InPorMat> getInPorMat(QueryFilter queryFilter) {
		return inPorMatDao.find(queryFilter);
	}
}
